package RJZ.Rainbow;

import RJZ.Rainbow.Config.MainConfig;
import RJZ.Rainbow.Controller.OrderController;
import RJZ.Rainbow.Controller.UIConruoller;
import RJZ.Rainbow.Service.OrderService;
import RJZ.Rainbow.Controller.SenserController;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.Executors;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {
        try {
            AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
            //HumanController humanController = context.getBean(HumanController.class);
            OrderService orderService=context.getBean(OrderService.class);
            OrderController orderController = context.getBean(OrderController.class);
            SenserController senserController = context.getBean(SenserController.class);
            UIConruoller uiConruoller=context.getBean(UIConruoller.class);
            orderController.link();
            senserController.link();
            senserController.init(orderController.getCh());
            orderService.init(senserController.getOut());
            Executors.newCachedThreadPool().execute(senserController);
            //Executors.newCachedThreadPool().execute(humanController);
            Executors.newCachedThreadPool().execute(orderController);
            uiConruoller.work();
        } catch (Exception e) {

        }
    }
}
